package com.atues.four;

public class Main {
    public static void main(String[] args) {
        //浅拷贝
        Person person1 = new Person(new Address("武汉"));
        Person person1Copy = person1.clone();
// true
        System.out.println(" person1 == person1Copy "+ (person1 == person1Copy));
        System.out.println( "person1.getAddress() == person1Copy.getAddress()" + ( person1.getAddress() == person1Copy.getAddress()));
        //验证是否为同一个内部对象
        System.out.println("person1.getAddress().getName() = " + person1.getAddress().getName());
        person1Copy.getAddress().setName("北京");
        System.out.println("person1Copy.getAddress().getName() = " + person1Copy.getAddress().getName());
        System.out.println("person1.getAddress().getName() = " + person1.getAddress().getName());
    }
}
